﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3.工长方法模式
{
    class Program
    {
        static void Main(string[] args)
        {
            LiveFactory liveFactory = new MusicFactory();
            Live musicLive = liveFactory.Create();
            musicLive.Action();
            Console.ReadLine();
        }
    }

    public abstract class Live
    {
        public abstract void Action();
    }
    public class Music : Live
    {
        public override void Action()
        {
            Console.WriteLine("哼哼哈嘿，快使用刷结棍！");
        }
    }
    public class Bread : Live
    {
        public override void Action()
        {
            Console.WriteLine("努力，面包会有的，鸡蛋也会有的。");
        }
    }
    public abstract class LiveFactory
    {
        public abstract Live Create();
    }
    public class MusicFactory : LiveFactory
    {
        public override Live Create()
        {
            return new Music();
        }
    }
    public class BreadFactory : LiveFactory
    {
        public override Live Create()
        {
            return new Bread();
        }
    }

}
